// Depends on tencentcloud-sdk-nodejs version 4.0.3 or higher
const tencentcloud = require("tencentcloud-sdk-nodejs");
const config = require("../config");

/* -------------------------------------------------------------------------- */
const FtClient = tencentcloud.ft.v20200304.Client;

const clientConfig = {
  credential: {
    secretId: config.secretId,
    secretKey: config.secretKey,
  },
  region: "ap-chengdu",
  profile: {
    httpProfile: {
      endpoint: "ft.tencentcloudapi.com",
    },
  },
};
const client = new FtClient(clientConfig);

module.exports = async function (ctx) {
  let JobId = ctx.request.body.JobId;

  if (!JobId) {
    console.log("没有参数: JobId");
    return {
      info: "请上传 JobId",
    };
  }

  const params = {
    JobId: JobId,
  };
  let data = await client.QueryFaceMorphJob(params).then(
    (data) => {
      console.log(data);
      return data;
    },
    (err) => {
      console.error("error", err);
    }
  );
  return data;
};
